﻿using Futajma.MigrationStudio.GenericPersistance.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LLTreeManagementApplication.Utils
{
    class DynamicMenuOperations
    {
        internal static ContextMenuStrip CreateDynamicLibraryMenu(LibraryTemplate libTemplateDef, EventHandler addEvent, EventHandler deleteEvent)
        {
            var contextStrip = new ContextMenuStrip();

            ToolStripMenuItem libMenu2 = new ToolStripMenuItem();
            libMenu2.Text = "Add new Folder";
            libMenu2.Enabled = libTemplateDef.CreateFolderAllowed;
            libMenu2.Click += addEvent;
            contextStrip.Items.Add(libMenu2);

            ToolStripMenuItem libMenu3 = new ToolStripMenuItem();
            libMenu3.Text = "Delete Library";
            libMenu3.Click += deleteEvent;
            contextStrip.Items.Add(libMenu3);            

            return contextStrip;
        }

        internal static void CreateSearchAndReplaceToolStripMenuItem(ContextMenuStrip menu, EventHandler selectEvent, bool enabled)
        {
            ToolStripSeparator separator = new ToolStripSeparator();
            menu.Items.Add(separator);

            ToolStripMenuItem searchAndReplaceDialog = new ToolStripMenuItem();
            searchAndReplaceDialog.Text = "Search And Replace";
            searchAndReplaceDialog.Click += selectEvent;
            searchAndReplaceDialog.Visible = true;
            searchAndReplaceDialog.Enabled = enabled;

            menu.Items.Add(searchAndReplaceDialog);
        }

        //private static void searchAndReplaceExportDialog_Click(object sender, EventArgs e)
        //{
        //    TreeView tv = (sender as ContextMenuStrip).SourceControl as TreeView;
        //    var node = tv.SelectedNode;


        //}
    }
}
